package com.sam.im.heiqun.uis.adapters.holder;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.sam.im.heiqun.R;
import com.sam.im.heiqun.uis.adapters.PhoneUsersAdpter;

/**
 * Created by wangguodong on 2017/1/8.
 */

public class PhoneUserHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    public final View mView;
    public final ImageView head_image;
    public final TextView name;
    public final TextView item_detail;
    public final Button yaoqing;
    private PhoneUsersAdpter.FriendListClickListener mFriendListClickListener;

    public PhoneUserHolder(View view, PhoneUsersAdpter.FriendListClickListener newFriendListClickListener) {
        super(view);
        mView = view;

        this.mFriendListClickListener = newFriendListClickListener;
        head_image = (ImageView) view.findViewById(R.id.img);
        name = (TextView) view.findViewById(R.id.item_name);
        item_detail = (TextView) view.findViewById(R.id.item_detail);
        yaoqing = (Button) view.findViewById(R.id.yaoqing);
        if (yaoqing != null) {
            yaoqing.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (mFriendListClickListener != null) {
                        mFriendListClickListener.onAgreeNewFriendClick(view, getAdapterPosition(), 1);
                    }
                }
            });
            view.setOnClickListener(this);
        }

    }

    public View getmView(){
        return mView;
    }

    @Override
    public void onClick(View v) {
        if (mFriendListClickListener != null) {
            mFriendListClickListener.onAgreeNewFriendClick(v, getAdapterPosition(), 0);
        }
    }
}